package Tests;

import java.util.Iterator;

import system.BlogSystem;
import bean.BlogBean;
import bean.UserBean;
import dao.BlogDAO;
import dao.DAO;
import dao.UserDAO;

public class UserStoryFacade14 {

	private BlogSystem system = BlogSystem.getInstance();
	private DAO<UserBean> userDAO = UserDAO.getInstance();
	private DAO<BlogBean> blogDAO = BlogDAO.getInstance();

	public void cleanPersistence() {
		Iterator<UserBean> users = userDAO.list().iterator();

		while (users.hasNext()) {
			UserBean anotherUser = users.next();
			userDAO.delete(anotherUser);
		}

		Iterator<BlogBean> blogs = blogDAO.list().iterator();

		while (blogs.hasNext()) {
			BlogBean anotherBlog = blogs.next();
			blogDAO.delete(anotherBlog);
		}
		system.finalize();
	}

	public void createProfile(String login, String senha, String nome_exibicao,
			String email, String sexo, String dataNasc, String endereco,
			String interesses, String quem_sou_eu, String filmes,
			String musicas, String livros) throws Exception {

		system.createUser(login, senha, nome_exibicao, email, sexo, dataNasc,
				endereco, interesses, quem_sou_eu, filmes, musicas, livros);
	}

	public String logon(String login, String senha) throws Exception {
		return system.login(login, senha);

	}

	public String createBlog(String sessionId, String title, String description)
			throws Exception {
		return system.createBlog(sessionId, title, description);
	}


	public String createPost(String sessionId, String blogId, String title,
			String text) throws Exception {
		return system.createPost(sessionId, blogId, title, text);

	}
	
	public String getNumberOfBlogsByLogin(String login) throws Exception{
		return String.valueOf(system.getNumberOfBlogsByLogin(login));
	}
	
	
	public String getNumberOfBlogsBySessionId(String sessionId) throws Exception{
		return String.valueOf(system.getNumberOfBlogsBySessionId(sessionId));
	}
	
	public String createSubBlog(String sessionId, String blogId, String title,
			String description) throws Exception {
		return system.createSubBlog(sessionId, blogId, title, description);

	}
	
	public String getNumberOfSubBlogs(String blogId) throws Exception{
		return String.valueOf(system.getNumberOfSubBlogs(blogId));
	}
	
	public String getNumberOfAllSubBlogs(String blogId) throws Exception{
		return String.valueOf(system.getNumberOfAllSubBlogs(blogId));
	}
	
	public String getSubBlog(String blogId, int index) throws Exception{
		return system.getSubBlog(blogId, index);
	}
	
	public String getNumberOfPosts(String blogId) throws Exception{
		return String.valueOf(system.getNumberOfPosts(blogId));
	}

	public String getNumberOfAllPosts(String blogId) throws Exception{
		return String.valueOf(system.getNumberOfAllPosts(blogId));
	}

	public String addComment(String sessionId, String postId, String texto) throws Exception{

		return system.addComment(sessionId, postId, texto);
	}
	
	public String addSubComment(String sessionId, String commentId, String texto) throws Exception{

		return system.addSubComment(sessionId, commentId, texto);
	}

	public String getComment(String postId, int index) throws Exception{
		return system.getComment(postId, index);
	}
	
	public String getSubComment(String commentId, int index) throws Exception{
		return system.getSubComment(commentId, index);
	}
	
	public String getNumberOfSubComments(String commentId) throws Exception{
		return String.valueOf(system.getNumberOfSubComments(commentId));
	}
	
	public String getNumberOfAllSubComments(String commentId) throws Exception{
		return String.valueOf(system.getNumberOfAllSubComments(commentId));
	}
	
	
	
	
	

	
	public void logoff(String idSession) throws Exception{
		system.logout(idSession);
	}
	public void saveData(){
		
	}
}
